import 'package:flutter/material.dart';

void main() {
  runApp(
    const MaterialApp(
      home: HomePage(),
    ),
  );
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final List<String> _list = ['我是一个默认列表'];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('flutter AppBar')),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            _list.add('我是一个新增列表');
          });
        },
        child: const Icon(Icons.add),
      ),
      body: ListView(
        children: _list.map((item) {
          return ListTile(title: Text(item));
        }).toList(),
      ),
    );
  }
}
